package sword_to_1;

import java.util.HashSet;
import java.util.Set;

public class LeeCode_46 {
    public static void main(String[] args) {
//        System.out.println(translateNum(12258));
        System.out.println(translateNum(506));
    }
    private static int translateNum(int num) {
        Set<String> set = new HashSet<>();
        dfs(num, set, "");
        return set.size();
    }
    private static void dfs(int num, Set<String> set, String s){
        if (num == 0){
            set.add(s);
            return;
        }
        char c1 = (char) (num % 10 + 'a');
        dfs(num / 10, set, c1 + s);
        if (num % 100 >= 10){
            int n2 = num % 100 + 'a';
            if (n2 >= 'a' && n2 <= 'z'){
                dfs(num / 100, set, (char) n2 + s);
            }
        }
    }
}
